Handle vscode.git activation failure in VS Code forks#603
Open
mukuliitkgp wants to merge 1 commit into
Open
Conversation
The extension crashes in VS Code forks like Kiro and Cursor because activating the built-in vscode.git extension throws an unhandled error. This wraps the activation call in a try/catch and adds a fallback that reads .git/config directly to discover remotes when the git extension is unavailable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The extension crashes in VS Code forks (Kiro, Cursor, etc.) where cross-extension activation of built-in extensions is restricted. This PR adds graceful error handling and a fallback so the extension works in all VS Code-compatible editors.
Problem
getGitExtension()insrc/git/repository.tscallsgitExtension.activate()without error handling. In VS Code forks, this throws "Cannot activate foreign extension" and crashes the entire extension. Users see "Unable to connect to the GitHub API" with no way to use the extension.What changed
gitExtension.activate()in try/catch — activation failures are now logged and the function returnsundefinedgracefully instead of crashinggetGitHubUrls()— whenvscode.gitis unavailable, the extension reads.git/configdirectly from workspace folders to discover GitHub repository remotesparseGitRemoteUrlinto its own module — keeps the parsing logic testable without pulling invscodedependenciesTesting
.git/configparsing covering SSH URLs, HTTPS URLs, enterprise URLs, remote name matching, and fallback behavioractivate()throwsRelated Issues
Fixes #582
Relates to #555, #590